package a_Map;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.stream.Collectors;

/**
 * @author Cheng-02
 * @version V1.0
 * @Package a_Map
 * @date 2024/4/11 下午6:30
 */
public class Test06 {
    public static void main(String[] args) {
        String[] arr = {"♥", "♦", "♣", "♠"};
        String[] number = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
        HashMap<Integer, String> poker = new HashMap<>();
//4.创建一个Arraylist，专门存储key
        ArrayList<Integer> list = new ArrayList<>();
        list.add(0);
        list.add(1);
        //5.组合牌，存储到map中
        int key = 2;
        for (String s : number) {
            for (String string : arr) {
                String pokernumber = s + string;
                poker.put(key, pokernumber);
                list.add(key);
                key++;
            }
        }
        poker.put(0, "大王");
        poker.put(1, "小王");
        System.out.println(list);
        System.out.println(poker);
        //6.洗牌：
        Collections.shuffle(list);
        //7.创建四个list集合
        ArrayList<Integer> p1 = new ArrayList<>();
        ArrayList<Integer> p2 = new ArrayList<>();
        ArrayList<Integer> p3 = new ArrayList<>();
        ArrayList<Integer> p4 = new ArrayList<>();
        //8.发牌
        for (int i = 0; i < list.size(); i++) {
            Integer key1 = list.get(i);
            if (i >= 51) {
                p4.add(key1);

            } else if (i % 3 == 0) {
                p1.add(key1);

            } else if (i % 3 == 1) {
                p2.add(key1);
            } else if (i % 3 == 2) {
                p3.add(key1);

            }
        }

        //9.排序
        Collections.sort(p1);
        Collections.sort(p2);
        Collections.sort(p3);
        Collections.sort(p4);
        System.out.println(p1);
        System.out.println(p2);
        System.out.println(p3);
        System.out.println(p4);
        lookpoker("张三", list, poker);


    }

    private static void lookpoker(String name, ArrayList<Integer> list, HashMap<Integer, String> map) {
        System.out.println(name + "");
        for (Integer key : list) {
            String value = map.get(key);
            System.out.println(key);
        }
        System.out.println();
    }
}
